#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <string.h>
using namespace std;

int n;
int h[1010];
const int mod = 998244353;
int f[1010][40010]; //表示前i个灯柱的方案数
long long ans = 0;
int p = 20000; //处理负数右移

int main()
{
    cin >> n;
    if (n == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    else if (n == 2)
    {
        cout << 3 << endl;
        return 0;
    }
    else if (n == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            cin >> h[i];
        }
        ans += n;
        for (int i = 1; i <= n; i++)
        {
            for (int j = i - 1; j > 0; j--)
            {
                f[i][h[i] - h[j] + p] += f[j][h[i] - h[j] + p] + 1;
                f[i][h[i] - h[j] + p] %= mod;
            }
        }
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= 40010; j++)
            {
                ans += f[i][j];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
   // system("pause");
    return 0;
}